<?php

class Core_Backend_Component_Foundation_View_Poi_Index extends Core_Backend_Share_View_Grid {

	protected function initialize(){
		parent::initialize();
		$this->setTemplatePath('index');
	}
	
    public function buildGrid($grid) {
        $this->getTemplate()->assign('users', $this->users);
        $filter = new Kd_Object($this->getRequest()->getParameter('filter'));
        $grid->setId('poi_grid')
                ->setPrimaryKey('id')
                ->setAllowFilter(TRUE)
                ->setSortField($this->getRequest()->getQuery('sort', 'id'))
                ->setSortDirection($this->getRequest()->getQuery('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('foundation.label.poi_id'), 'poiid', '{id}')
                ->setTextboxFilter(NULL, NULL, $filter->getData('poiid'))
                ->setSortField('poi');
        $grid->addLabelColumn($this->__('foundation.label.shop_name'), 'shopname', '{shop_name}')
                ->setTextboxFilter(NULL, NULL, $filter->getData('shopname'))
                ->setSortField('shopname')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('foundation.label.industry'), 'industryname', '{industry_{industry_id}}')
                ->setTextboxFilter(NULL, NULL, $filter->getData('industryname'))
                ->setSortField('industryname');
        $grid->addLabelColumn($this->__('foundation.label.road'), 'roadname', '{road_{road_id}}')
                ->setTextboxFilter(NULL, NULL, $filter->getData('roadname'))
                ->setSortField('roadname');	
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $pagination->setUrlFormat($this->getPaginationUrl())->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}

